
$.fn.extend({
    dialog:function(params){
        var object={"title":"默认标题","btnValue":"确定","btnBind":null}
        for(var obj in object){
            object[obj] = params[obj]||object[obj];
        }

        if(typeof(params)=="object"){
            var html = '<div class="modal fade" id="mymodal" data-backdrop="static" data-keyboard="false">\
                <div class="modal-dialog">\
                <div class="modal-content">\
                <div class="modal-header">\
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>\
            <h4 class="modal-title"></h4>\
            </div>\
            <div class="modal-body">\
                </div>\
                <div class="modal-footer">\
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>\
                <button type="button" class="btn btn-primary">确定</button>\
            </div>\
            </div>\
            </div>\
            </div>';
            var $modal = $(html);
            $modal.find(".modal-title").html(object.title);
            this.children("*").appendTo($modal.find(".modal-body"));
            $modal.find(":button:last").html(object.btnValue);
            $modal.find(":button:last").off("click").on("click",object.btnBind);
            $modal.appendTo(this);
        }else if(params=="open"){
            this.find(".modal").modal("show");
        }else if(params=="close"){
            this.find(".modal").modal("hide");
        }
    }
})